/*
 * BncsHeader.h
 *
 *  Created on: Nov 20, 2008
 *      Author: nathan
 */

#ifndef BNCSHEADER_H_
#define BNCSHEADER_H_

class BncsHeader
{
	public:
		quint8 startByte;
		quint8 messageId;
		quint16 packetLen;

	public:
		int size()
		{
			return sizeof(startByte) + sizeof(messageId) + sizeof(packetLen);
		}

		void readFrom(QDataStream& ds)
		{
			int bo = ds.byteOrder();
			ds.setByteOrder(QDataStream::LittleEndian);

			ds >> startByte;
			ds >> messageId;
			ds >> packetLen;

			ds.setByteOrder((QDataStream::ByteOrder)bo);
		}

		void writeTo(QDataStream& ds)
		{
			int bo = ds.byteOrder();
			ds.setByteOrder(QDataStream::LittleEndian);

			ds << startByte;
			ds << messageId;
			ds << packetLen;

			ds.setByteOrder((QDataStream::ByteOrder)bo);
		}
};

#endif /* BNCSHEADER_H_ */
